﻿using System.Collections.Generic;
using System.Linq;
using RepositoryAndEf.Core.Data;

namespace RepositoryAndEf.Domain
{
    public class OrderFactory
    {
        public virtual Order Create(ShoppingCart ShoppingCart)
        {
            var order = new Order
            {
                Customer = ShoppingCart.Customer,
                Items = ShoppingCart.Items.Select(item => new OrderItem()
                {
                    Product = item.Product,
                    Quantity = item.Quantity
                }).ToList()
            };

            return order;
        }
    }


}
